x86/time: implement PVCLOCK_TSC_STABLE_BIT
authorJoao Martins <joao.m.martins@oracle.com>
Fri, 23 Sep 2016 16:25:49 +0000 (18:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 23 Sep 2016 16:25:49 +0000 (18:25 +0200)
commitfe0364d29323cf2acccdf37d000f6c2f2f7267df
treeb263b52eb0db9836f69103f0dce778ab01e38922
parent15c3ef8b5e177d208ed24ccc7ea0d032aa25b16d
x86/time: implement PVCLOCK_TSC_STABLE_BIT

This patch proposes relying on host TSC synchronization and
passthrough to the guest, when running on a TSC-safe platform. On
time_calibration we retrieve the platform time in ns and the counter
read by the clocksource that was used to compute system time. We can
guarantee that on a platform with a constant and reliable TSC, that the
time read on vcpu B right after A is bigger independently of the VCPU
calibration error. Since pvclock time infos are monotonic as seen by any
vCPU set PVCLOCK_TSC_STABLE_BIT, which then enables usage of VDSO on
Linux.  IIUC, this is similar to how it's implemented on KVM. Add also a
comment regarding this bit changing and that guests are expected to
check this bit on every read.

Should note that I've yet to see time going backwards in a long running
test I ran for 2 weeks (in a dual socket machine), plus few other
tests I did on older platforms.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/time.c